home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / dec92.zip / 1012018C < prev    next >
Text File  |  1992-10-06  |  443b  |  21 lines

  1. /* strstr function */
  2. #include <string.h>
  3.  
  4. char *(strstr)(const char *s1, const char *s2)
  5.     {    /* find first occurrence of s2[] in s1[] */
  6.     if (*s2 == '\0')
  7.         return ((char *)s1);
  8.     for (; (s1 = strchr(s1, *s2)) != NULL; ++s1)
  9.         {    /* match rest of prefix */
  10.         const char *sc1, *sc2;
  11.  
  12.         for (sc1 = s1, sc2 = s2; ; )
  13.             if (*++sc2 == '\0')
  14.                 return ((char *)s1);
  15.             else if (*++sc1 != *sc2)
  16.                 break;
  17.         }
  18.     return (NULL);
  19.     }
  20.  
  21.